var a = getApp();

Page({
    data: {
        url: "plugin.product-market.api.order.index",
        PopupShow: !1,
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        serviceDetailsShow: !1,
        erviceNetword: !1,
        current_domain: "",
        remaining_time: 0,
        service_allLoad: !1,
        service_isLoadMore: !0,
        service_page: 1,
        service_total_page: 0,
        service_listData: [],
        service_show: 0,
        serviceContentScroll: null
    },
    onLoad: function(a) {
        1 == a.marketSub && this.setData({
            url: "plugin.market-sub.api.order.index"
        }), this.getdata();
    },
    tapPopupShow: function(a) {
        console.log(a);
        var e = a.currentTarget.dataset.item, t = a.currentTarget.dataset.good;
        console.log(t);
        for (var s = 0; s < e.has_market_product.widget.length; s++) console.log(t.goods_id, e.has_market_product.widget[s].goods_id), 
        t.goods_id === e.has_market_product.widget[s].goods_id && this.setData({
            showList: e.has_market_product.widget[s].widget.plugin
        });
        this.setData({
            PopupShow: !0
        });
    },
    closs_tap: function() {
        this.setData({
            PopupShow: !1
        });
    },
    setServiceDetailsShow: function() {
        this.setData({
            serviceDetailsShow: !this.data.serviceDetailsShow
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    getdata: function() {
        wx.showLoading({
            title: "加载中"
        });
        var e = this, t = a.getNetAddresss(this.data.url);
        a._getNetWork({
            url: t,
            data: {
                page: e.data.page
            },
            success: function(a) {
                wx.hideLoading();
                var t = a.data;
                1 == t.result ? e.setData({
                    domain: t.data.domain,
                    order: t.data.order.data,
                    page: t.data.order.current_page,
                    total_page: t.data.order.last_page,
                    current_domain: t.data.current_domain,
                    remaining_time: t.data.remaining_time,
                    service_show: t.data.service_show
                }) : wx.showToast({
                    icon: "none",
                    title: t.msg,
                    duration: 1500
                });
            },
            fail: function(a) {
                wx.hideLoading({
                    complete: function(a) {}
                });
            }
        });
    },
    _getMoreData: function() {
        var e = this, t = a.getNetAddresss(this.data.url);
        this.data.page >= this.data.total_page ? e.setData({
            isLoadMore: !1
        }) : (e.setData({
            page: this.data.page + 1
        }), a._getNetWork({
            url: t,
            data: {
                page: e.data.page
            },
            success: function(a) {
                var t = a.data;
                1 == t.result ? e.setData({
                    isLoadMore: !0,
                    order: e.data.order.concat(t.data.order.data)
                }) : e.setData({
                    page: e.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(a) {
                wx.hideLoading();
            }
        }));
    },
    getServiceDetails: function() {
        var e = this;
        if (this.data.serviceNetword) this.setData({
            serviceDetailsShow: !0
        }); else {
            this.data.serviceNetword = !0;
            var t = a.getNetAddresss("plugin.product-market.api.order.index.check-record");
            1 == this.options.marketSub && (t = a.getNetAddresss("plugin.market-sub.api.order.index.check-record")), 
            a._getNetWork({
                url: t,
                data: {
                    page: this.data.service_page
                },
                success: function(t) {
                    var s = t.data;
                    1 == s.result ? e.setData({
                        service_listData: s.data.data,
                        service_total_page: s.data.last_page,
                        serviceDetailsShow: !0
                    }) : a.tips(s.msg);
                }
            });
        }
    },
    getMoreServiceDetails: function() {
        var e = this;
        if (this.data.service_isLoadMore) if (!this.data.service_allLoad && this.data.service_page >= this.data.service_total_page) this.setData({
            service_allLoad: !0,
            service_isLoadMore: !1
        }); else {
            this.data.service_isLoadMore = !1;
            var t = a.getNetAddresss("plugin.market-sub.api.order.index.check-record");
            this.data.service_page++, a._getNetWork({
                url: t,
                data: {
                    page: this.data.service_page
                },
                success: function(t) {
                    var s = t.data;
                    if (1 == s.result) {
                        var i = response.data.data;
                        e.setData({
                            service_isLoadMore: !0,
                            service_listData: e.data.service_listData.concat(i)
                        });
                    } else e.data.service_isLoadMore = !1, a.tips(s.msg);
                }
            });
        }
    }
});